<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: PubSubService.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">PubSubService.h</div></div>
</div><!--header-->
<div class="contents">
<a href="PubSubService_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span> </div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#include &lt;trantor/utils/NonCopyable.h&gt;</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#include &lt;mutex&gt;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &lt;shared_mutex&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;memory&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#include &lt;unordered_map&gt;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacedrogon.html">drogon</a></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span>{</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">   27</a></span><span class="keyword">using </span><a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> = uint64_t;</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> MessageType&gt;</div>
<div class="foldopen" id="foldopen00035" data-start="{" data-end="};">
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html">   35</a></span><span class="keyword">class </span><a class="code hl_class" href="classdrogon_1_1Topic.html">Topic</a> : <span class="keyword">public</span> trantor::NonCopyable</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>{</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>  <span class="keyword">public</span>:</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">   38</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> = std::function&lt;void(<span class="keyword">const</span> MessageType &amp;)&gt;;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="preprocessor">#if __cplusplus &gt;= 201703L | defined _WIN32</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">SharedMutex</a> = std::shared_mutex;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">   42</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">SharedMutex</a> = std::shared_timed_mutex;</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="preprocessor">#endif</span></div>
<div class="foldopen" id="foldopen00050" data-start="{" data-end="}">
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a64924c059baa1475f4640ed3593d7e3b">   50</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1Topic.html#a64924c059baa1475f4640ed3593d7e3b">publish</a>(<span class="keyword">const</span> MessageType &amp;message)<span class="keyword"> const</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>        std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>        <span class="keywordflow">for</span> (<span class="keyword">auto</span> &amp;pair : handlersMap_)</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>        {</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>            pair.second(message);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span>        }</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>    }</div>
</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span> </div>
<div class="foldopen" id="foldopen00065" data-start="{" data-end="}">
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a4b85d748b06aa39438ee90846e46bc2c">   65</a></span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="code hl_function" href="classdrogon_1_1Topic.html#a4b85d748b06aa39438ee90846e46bc2c">subscribe</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;handler)</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>    {</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>        handlersMap_[++id_] = handler;</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>        <span class="keywordflow">return</span> id_;</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>    }</div>
</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span> </div>
<div class="foldopen" id="foldopen00078" data-start="{" data-end="}">
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a9b2d54de15b953cb98712c3ced46b0c5">   78</a></span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="code hl_function" href="classdrogon_1_1Topic.html#a9b2d54de15b953cb98712c3ced46b0c5">subscribe</a>(<a class="code hl_typedef" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">MessageHandler</a> &amp;&amp;handler)</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>    {</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>        handlersMap_[++id_] = std::move(handler);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>        <span class="keywordflow">return</span> id_;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>    }</div>
</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span> </div>
<div class="foldopen" id="foldopen00088" data-start="{" data-end="}">
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a5a1f20d1a2e6b186fa16ea6f30589933">   88</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1Topic.html#a5a1f20d1a2e6b186fa16ea6f30589933">unsubscribe</a>(<a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <span class="keywordtype">id</span>)</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span>    {</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>        handlersMap_.erase(<span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    }</div>
</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span> </div>
<div class="foldopen" id="foldopen00100" data-start="{" data-end="}">
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a3a04d2de037c697b61176418aff5544b">  100</a></span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="classdrogon_1_1Topic.html#a3a04d2de037c697b61176418aff5544b">empty</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>        std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>        <span class="keywordflow">return</span> handlersMap_.empty();</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    }</div>
</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span> </div>
<div class="foldopen" id="foldopen00110" data-start="{" data-end="}">
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"><a class="line" href="classdrogon_1_1Topic.html#a202a7f4f40b4437133cba1efdfad9407">  110</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1Topic.html#a202a7f4f40b4437133cba1efdfad9407">clear</a>()</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>    {</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>        handlersMap_.clear();</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>    }</div>
</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span> </div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>  <span class="keyword">private</span>:</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    std::unordered_map&lt;SubscriberID, MessageHandler&gt; handlersMap_;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>    <span class="keyword">mutable</span> <a class="code hl_typedef" href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">SharedMutex</a> mutex_;</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> id_{0};</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>};</div>
</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span> </div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span><span class="keyword">template</span> &lt;<span class="keyword">typename</span> MessageType&gt;</div>
<div class="foldopen" id="foldopen00129" data-start="{" data-end="};">
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html">  129</a></span><span class="keyword">class </span><a class="code hl_class" href="classdrogon_1_1PubSubService.html">PubSubService</a> : <span class="keyword">public</span> trantor::NonCopyable</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>{</div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>  <span class="keyword">public</span>:</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">  132</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> =</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>        std::function&lt;void(<span class="keyword">const</span> std::string &amp;, <span class="keyword">const</span> MessageType &amp;)&gt;;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span><span class="preprocessor">#if __cplusplus &gt;= 201703L | defined _WIN32</span></div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">SharedMutex</a> = std::shared_mutex;</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">  137</a></span>    <span class="keyword">using </span><a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">SharedMutex</a> = std::shared_timed_mutex;</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span> </div>
<div class="foldopen" id="foldopen00144" data-start="{" data-end="}">
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a4eb1570db8e7cd3b52c0a9d6a1aaab7f">  144</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#a4eb1570db8e7cd3b52c0a9d6a1aaab7f">publish</a>(<span class="keyword">const</span> std::string &amp;topicName, <span class="keyword">const</span> MessageType &amp;message)<span class="keyword"> const</span></div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>        std::shared_ptr&lt;Topic&lt;MessageType&gt;&gt; topicPtr;</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span>        {</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>            std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>            <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>            <span class="keywordflow">if</span> (iter != topicMap_.end())</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>            {</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>                topicPtr = iter-&gt;second;</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>            }</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>            <span class="keywordflow">else</span></div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>            {</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>                <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>            }</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>        }</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>        topicPtr-&gt;publish(message);</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>    }</div>
</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span> </div>
<div class="foldopen" id="foldopen00166" data-start="{" data-end="}">
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a7cf825d629c9bd39b8c48d038511bb69">  166</a></span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#a7cf825d629c9bd39b8c48d038511bb69">subscribe</a>(<span class="keyword">const</span> std::string &amp;topicName,</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>                           <span class="keyword">const</span> <a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;handler)</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span>    {</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span>        <span class="keyword">auto</span> topicHandler = [topicName, handler](<span class="keyword">const</span> MessageType &amp;message) {</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span>            handler(topicName, message);</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span>        };</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span>        <span class="keywordflow">return</span> subscribeToTopic(topicName, std::move(topicHandler));</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span>    }</div>
</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span> </div>
<div class="foldopen" id="foldopen00182" data-start="{" data-end="}">
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a3f36abdc474cfbac205bf9a0ea63d064">  182</a></span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#a3f36abdc474cfbac205bf9a0ea63d064">subscribe</a>(<span class="keyword">const</span> std::string &amp;topicName,</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span>                           <a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;&amp;handler)</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span>    {</div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>        <span class="keyword">auto</span> topicHandler = [topicName, handler = std::move(handler)](</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>                                <span class="keyword">const</span> MessageType &amp;message) {</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>            handler(topicName, message);</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>        };</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>        <span class="keywordflow">return</span> subscribeToTopic(topicName, std::move(topicHandler));</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>    }</div>
</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span> </div>
<div class="foldopen" id="foldopen00198" data-start="{" data-end="}">
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#aa4e93f776603051dbd3f2da52ec34395">  198</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#aa4e93f776603051dbd3f2da52ec34395">unsubscribe</a>(<span class="keyword">const</span> std::string &amp;topicName, <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <span class="keywordtype">id</span>)</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>    {</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>        {</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span>            std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span>            <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span>            <span class="keywordflow">if</span> (iter == topicMap_.end())</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno">  204</span>            {</div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno">  205</span>                <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno">  206</span>            }</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span>            iter-&gt;second-&gt;unsubscribe(<span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno">  208</span>            <span class="keywordflow">if</span> (!iter-&gt;second-&gt;empty())</div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno">  209</span>                <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span>        }</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno">  212</span>        <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno">  213</span>        <span class="keywordflow">if</span> (iter == topicMap_.end())</div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno">  214</span>        {</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno">  215</span>            <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno">  216</span>        }</div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno">  217</span>        <span class="keywordflow">if</span> (iter-&gt;second-&gt;empty())</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno">  218</span>            topicMap_.erase(iter);</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span>    }</div>
</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span> </div>
<div class="foldopen" id="foldopen00224" data-start="{" data-end="}">
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#ad0db22a9172a36b5358284c570dcb7ae">  224</a></span>    <span class="keywordtype">size_t</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#ad0db22a9172a36b5358284c570dcb7ae">size</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>        std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span>        <span class="keywordflow">return</span> topicMap_.size();</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span>    }</div>
</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span> </div>
<div class="foldopen" id="foldopen00233" data-start="{" data-end="}">
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a49beac8cd7262016b452049851fba22a">  233</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#a49beac8cd7262016b452049851fba22a">clear</a>()</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>    {</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span>        topicMap_.clear();</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span>    }</div>
</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span> </div>
<div class="foldopen" id="foldopen00243" data-start="{" data-end="}">
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#adf4f371214a0ceaff8d4e9211363ccf5">  243</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#adf4f371214a0ceaff8d4e9211363ccf5">removeTopic</a>(<span class="keyword">const</span> std::string &amp;topicName)</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno">  244</span>    {</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno">  245</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span>        topicMap_.erase(topicName);</div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno">  247</span>    }</div>
</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno">  248</span> </div>
<div class="foldopen" id="foldopen00256" data-start="{" data-end="}">
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno"><a class="line" href="classdrogon_1_1PubSubService.html#a20c777adfb76690d9c1c53ac27eabff1">  256</a></span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="classdrogon_1_1PubSubService.html#a20c777adfb76690d9c1c53ac27eabff1">isTopicEmpty</a>(<span class="keyword">const</span> std::string &amp;topicName)<span class="keyword"> const</span></div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span><span class="keyword">    </span>{</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span>        std::shared_ptr&lt;Topic&lt;MessageType&gt;&gt; topicPtr;</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span>        {</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>            std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>            <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span>            <span class="keywordflow">if</span> (iter != topicMap_.end())</div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span>            {</div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno">  264</span>                topicPtr = iter-&gt;second;</div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno">  265</span>            }</div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno">  266</span>            <span class="keywordflow">else</span></div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno">  267</span>            {</div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno">  268</span>                <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno">  269</span>            }</div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno">  270</span>        }</div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno">  271</span>        <span class="keywordflow">return</span> topicPtr-&gt;empty();</div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno">  272</span>    }</div>
</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno">  273</span> </div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno">  274</span>  <span class="keyword">private</span>:</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno">  275</span>    std::unordered_map&lt;std::string, std::shared_ptr&lt;Topic&lt;MessageType&gt;&gt;&gt;</div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno">  276</span>        topicMap_;</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno">  277</span>    <span class="keyword">mutable</span> <a class="code hl_typedef" href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">SharedMutex</a> mutex_;</div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno">  278</span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> subID_ = 0;</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span> </div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span>    <a class="code hl_typedef" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> subscribeToTopic(</div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno">  281</span>        <span class="keyword">const</span> std::string &amp;topicName,</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno">  282</span>        <span class="keyword">typename</span> <a class="code hl_typedef" href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">Topic&lt;MessageType&gt;::MessageHandler</a> &amp;&amp;handler)</div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno">  283</span>    {</div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno">  284</span>        {</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno">  285</span>            std::shared_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno">  286</span>            <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno">  287</span>            <span class="keywordflow">if</span> (iter != topicMap_.end())</div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno">  288</span>            {</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno">  289</span>                <span class="keywordflow">return</span> iter-&gt;second-&gt;subscribe(std::move(handler));</div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno">  290</span>            }</div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno">  291</span>        }</div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno">  292</span>        std::unique_lock&lt;SharedMutex&gt; lock(mutex_);</div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno">  293</span>        <span class="keyword">auto</span> iter = topicMap_.find(topicName);</div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno">  294</span>        <span class="keywordflow">if</span> (iter != topicMap_.end())</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno">  295</span>        {</div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno">  296</span>            <span class="keywordflow">return</span> iter-&gt;second-&gt;subscribe(std::move(handler));</div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno">  297</span>        }</div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno">  298</span>        <span class="keyword">auto</span> topicPtr = std::make_shared&lt;Topic&lt;MessageType&gt;&gt;();</div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno">  299</span>        <span class="keyword">auto</span> <span class="keywordtype">id</span> = topicPtr-&gt;subscribe(std::move(handler));</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno">  300</span>        topicMap_[topicName] = std::move(topicPtr);</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno">  301</span>        <span class="keywordflow">return</span> id;</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span>    }</div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno">  303</span>};</div>
</div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno">  304</span>}  <span class="comment">// namespace drogon</span></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html"><div class="ttname"><a href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a></div><div class="ttdoc">This class template implements a publish-subscribe pattern with multiple named topics.</div><div class="ttdef"><b>Definition</b> PubSubService.h:130</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a20c777adfb76690d9c1c53ac27eabff1"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a20c777adfb76690d9c1c53ac27eabff1">drogon::PubSubService::isTopicEmpty</a></div><div class="ttdeci">bool isTopicEmpty(const std::string &amp;topicName) const</div><div class="ttdoc">Check if a topic is empty.</div><div class="ttdef"><b>Definition</b> PubSubService.h:256</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a2c701a64f6958bfd4d33fbbb83a944c0"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">drogon::PubSubService::SharedMutex</a></div><div class="ttdeci">std::shared_timed_mutex SharedMutex</div><div class="ttdef"><b>Definition</b> PubSubService.h:137</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a3f36abdc474cfbac205bf9a0ea63d064"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a3f36abdc474cfbac205bf9a0ea63d064">drogon::PubSubService::subscribe</a></div><div class="ttdeci">SubscriberID subscribe(const std::string &amp;topicName, MessageHandler &amp;&amp;handler)</div><div class="ttdoc">Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the...</div><div class="ttdef"><b>Definition</b> PubSubService.h:182</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a49beac8cd7262016b452049851fba22a"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a49beac8cd7262016b452049851fba22a">drogon::PubSubService::clear</a></div><div class="ttdeci">void clear()</div><div class="ttdoc">remove all topics.</div><div class="ttdef"><b>Definition</b> PubSubService.h:233</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a4eb1570db8e7cd3b52c0a9d6a1aaab7f"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a4eb1570db8e7cd3b52c0a9d6a1aaab7f">drogon::PubSubService::publish</a></div><div class="ttdeci">void publish(const std::string &amp;topicName, const MessageType &amp;message) const</div><div class="ttdoc">Publish a message to a topic. The message will be broadcasted to every subscriber.</div><div class="ttdef"><b>Definition</b> PubSubService.h:144</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_a7cf825d629c9bd39b8c48d038511bb69"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#a7cf825d629c9bd39b8c48d038511bb69">drogon::PubSubService::subscribe</a></div><div class="ttdeci">SubscriberID subscribe(const std::string &amp;topicName, const MessageHandler &amp;handler)</div><div class="ttdoc">Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the...</div><div class="ttdef"><b>Definition</b> PubSubService.h:166</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_aa4e93f776603051dbd3f2da52ec34395"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#aa4e93f776603051dbd3f2da52ec34395">drogon::PubSubService::unsubscribe</a></div><div class="ttdeci">void unsubscribe(const std::string &amp;topicName, SubscriberID id)</div><div class="ttdoc">Unsubscribe from a topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:198</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_ad0db22a9172a36b5358284c570dcb7ae"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#ad0db22a9172a36b5358284c570dcb7ae">drogon::PubSubService::size</a></div><div class="ttdeci">size_t size() const</div><div class="ttdoc">return the number of topics.</div><div class="ttdef"><b>Definition</b> PubSubService.h:224</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_adf4f371214a0ceaff8d4e9211363ccf5"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#adf4f371214a0ceaff8d4e9211363ccf5">drogon::PubSubService::removeTopic</a></div><div class="ttdeci">void removeTopic(const std::string &amp;topicName)</div><div class="ttdoc">Remove a topic</div><div class="ttdef"><b>Definition</b> PubSubService.h:243</div></div>
<div class="ttc" id="aclassdrogon_1_1PubSubService_html_aef09df9e6709fdde595323fb86fc8c9e"><div class="ttname"><a href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">drogon::PubSubService::MessageHandler</a></div><div class="ttdeci">std::function&lt; void(const std::string &amp;, const MessageType &amp;)&gt; MessageHandler</div><div class="ttdef"><b>Definition</b> PubSubService.h:133</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html"><div class="ttname"><a href="classdrogon_1_1Topic.html">drogon::Topic</a></div><div class="ttdoc">This class template presents an unnamed topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:36</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a202a7f4f40b4437133cba1efdfad9407"><div class="ttname"><a href="classdrogon_1_1Topic.html#a202a7f4f40b4437133cba1efdfad9407">drogon::Topic::clear</a></div><div class="ttdeci">void clear()</div><div class="ttdoc">Remove all subscribers from the topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:110</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a3a04d2de037c697b61176418aff5544b"><div class="ttname"><a href="classdrogon_1_1Topic.html#a3a04d2de037c697b61176418aff5544b">drogon::Topic::empty</a></div><div class="ttdeci">bool empty() const</div><div class="ttdoc">Check if the topic is empty.</div><div class="ttdef"><b>Definition</b> PubSubService.h:100</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a4b85d748b06aa39438ee90846e46bc2c"><div class="ttname"><a href="classdrogon_1_1Topic.html#a4b85d748b06aa39438ee90846e46bc2c">drogon::Topic::subscribe</a></div><div class="ttdeci">SubscriberID subscribe(const MessageHandler &amp;handler)</div><div class="ttdoc">Subscribe to the topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:65</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a5a1f20d1a2e6b186fa16ea6f30589933"><div class="ttname"><a href="classdrogon_1_1Topic.html#a5a1f20d1a2e6b186fa16ea6f30589933">drogon::Topic::unsubscribe</a></div><div class="ttdeci">void unsubscribe(SubscriberID id)</div><div class="ttdoc">Unsubscribe from the topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:88</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a64924c059baa1475f4640ed3593d7e3b"><div class="ttname"><a href="classdrogon_1_1Topic.html#a64924c059baa1475f4640ed3593d7e3b">drogon::Topic::publish</a></div><div class="ttdeci">void publish(const MessageType &amp;message) const</div><div class="ttdoc">Publish a message, every subscriber in the topic will receive the message.</div><div class="ttdef"><b>Definition</b> PubSubService.h:50</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a803792904817c4cb758ee1b57ebdd7b2"><div class="ttname"><a href="classdrogon_1_1Topic.html#a803792904817c4cb758ee1b57ebdd7b2">drogon::Topic::MessageHandler</a></div><div class="ttdeci">std::function&lt; void(const MessageType &amp;)&gt; MessageHandler</div><div class="ttdef"><b>Definition</b> PubSubService.h:38</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_a9b2d54de15b953cb98712c3ced46b0c5"><div class="ttname"><a href="classdrogon_1_1Topic.html#a9b2d54de15b953cb98712c3ced46b0c5">drogon::Topic::subscribe</a></div><div class="ttdeci">SubscriberID subscribe(MessageHandler &amp;&amp;handler)</div><div class="ttdoc">Subscribe to the topic.</div><div class="ttdef"><b>Definition</b> PubSubService.h:78</div></div>
<div class="ttc" id="aclassdrogon_1_1Topic_html_ab3f96c1355b779606f9adf322ae653aa"><div class="ttname"><a href="classdrogon_1_1Topic.html#ab3f96c1355b779606f9adf322ae653aa">drogon::Topic::SharedMutex</a></div><div class="ttdeci">std::shared_timed_mutex SharedMutex</div><div class="ttdef"><b>Definition</b> PubSubService.h:42</div></div>
<div class="ttc" id="anamespacedrogon_html"><div class="ttname"><a href="namespacedrogon.html">drogon</a></div><div class="ttdoc">Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...</div><div class="ttdef"><b>Definition</b> Attribute.h:23</div></div>
<div class="ttc" id="anamespacedrogon_html_a7f1da84a8169f7a3aefb1403cc16bae9"><div class="ttname"><a href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">drogon::SubscriberID</a></div><div class="ttdeci">uint64_t SubscriberID</div><div class="ttdef"><b>Definition</b> PubSubService.h:27</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
